/**
 * Storage二次封装
 * 目前只存appname空间 后续会考虑大项目的分namespace
 *
 */

export const setItem = (key: string, val: any) => {
  let storage = getStroage();
  storage[key] = val;
  window.localStorage.setItem(APP_NAME, JSON.stringify(storage));
};
export const getItem = (key: string) => {
  return getStroage()[key];
};
export const getStroage = () => {
  return JSON.parse(window.localStorage.getItem(APP_NAME) || '{}');
};
export const clearItem = (key: string) => {
  let storage = getStroage();
  delete storage[key];
  window.localStorage.setItem(APP_NAME, JSON.stringify(storage));
};
export const clearAll = () => {
  window.localStorage.clear();
};
